﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _005ATM机模拟
{
    class Program
    {
        static void Main(string[] args)
        {
            //Todo 1.银行开户
            BankAccount acc1 = new BankAccount("王小虎", "ChinaBank0080011", 50);
            acc1.Password = "123456";
            BankAccount acc2 = new BankAccount("张小猫", "ChinaBank0080012", 500);
            acc2.Password = "000000";
            BankAccount acc3 = new BankAccount("李小舒", "ChinaBank0080013", 150);
            acc3.Password = "555555";
            //Todo 5.给列表开辟内存
            ATM.accountList = new List<BankAccount>();
            //Todo 6.将账户信息加入到列表
            ATM.accountList.Add(acc1);
            ATM.accountList.Add(acc2);
            ATM.accountList.Add(acc3);
            //Todo 2.通过ATM机打印所有账户信息
            //ATM.PrintAllBankAccount();
            //Todo 8.提示用于插入银行卡
            Console.WriteLine("请插入您的银联卡:");
            //Todo 9.读取用户的账号
            string accountID = Console.ReadLine();
            //Todo 10.在数据库里搜寻该账号是否存在
            ATM atm = new ATM();//创建一个ATM机实例,展示实例方法的使用
            if(atm.SearchAccount(accountID))
            {
                //账户存在
                //Console.WriteLine("该账户存在");
                //Todo 12.提示用户输入密码           
                string password ;
                int count = 0;//次数
                //Todo 13.比对账户密码
                do
                {
                    Console.WriteLine("请输入您的密码:");
                    password = Console.ReadLine();
                    if (atm.Verifypassword(password))
                    {
                        //Console.WriteLine("密码正确");
                        break;
                    }else
                        Console.WriteLine("密码错误，请重新输入:");
                } while (++count < 3);

                //展示欢迎界面及各种操作
                Console.WriteLine("*******欢迎使用中国银行ATM机终端0.1版********");
            }  
            else
                Console.WriteLine("该账户不存在");



        }
    }
}
